package com.snu.liwei.lyl_api.tools;

import java.io.Serializable;
import java.util.Map;

public class UMsg implements Serializable {
    private Boolean success;
    private Integer code;
    //private Map<String,Object> data;
    private Object data;
    private UMsg(){}

    public Boolean getSuccess() {
        return success;
    }

    public void setSuccess(Boolean success) {
        this.success = success;
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }

    public static UMsg ok(){
        UMsg msg=new UMsg();
        msg.success=true;
        msg.code=1000;
        return msg;
    }

    public static UMsg ok(Object data){
        //System.out.println("构造统一消息");
        UMsg msg=new UMsg();
        msg.success=true;
        msg.code=1000;
        msg.data=data;
        return msg;
    }

    public static UMsg failed(){
        //System.out.println("构造统一消息");
        UMsg msg=new UMsg();
        msg.success=false;
        msg.code=2000;
        return msg;
    }

    public static UMsg failed(Object data){
        UMsg msg=new UMsg();
        msg.success=false;
        msg.code=2000;
        msg.data=data;
        return msg;
    }

    @Override
    public String toString() {
        return "UMsg{" +
                "success=" + success +
                ", code=" + code +
                ", data=" + data +
                '}';
    }
}
